package cn.wolfcode.luowowo.article.service.impl;

import cn.wolfcode.luowowo.article.domain.Scenic;
import cn.wolfcode.luowowo.article.mapper.ScenicMapper;
import cn.wolfcode.luowowo.article.service.IScenicService;
import cn.wolfcode.luowowo.comment.query.ScenicQueryObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class ScenicServiceImpl implements IScenicService {
    @Autowired
    private ScenicMapper scenicMapper;


    @Override
    public List<Scenic> selectAll() {
        return scenicMapper.selectAll();
    }

    @Override
    public Scenic selectByPrimaryKey(Long id) {
        return scenicMapper.selectByPrimaryKey(id);
    }

    @Override
    public void saveOrUpdate(Scenic scenic) {
        scenicMapper.updateByPrimaryKey(scenic);
    }

    @Override
    public List<Scenic> selectByDestId(Long id) {
        return null;
    }

    @Override
    public List<Scenic> selectByTOP5(Long destId) {
        return scenicMapper.selectByTOP5(destId);
    }

    @Override
    public List<Scenic> selectByHot() {
        return scenicMapper.selectByHot();
    }

    @Override
    public PageInfo query(ScenicQueryObject qo) {
        qo.setPageSize(15);
        PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize());
        List<Scenic> list = scenicMapper.query4List(qo);
        return new PageInfo(list);
    }
}
